package com.hz.Tech2Real.yeyouwang.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Tech2RealZCdao {
	private static final String driver ="com.mysql.jdbc.Driver";
	private static final String url = "jdbc:mysql://192.168.50.51:3306/tech2real";
	private static final String user = "root";
	private static final String PASSWORD = "root";
	
	Connection conn = null;
	PreparedStatement ps = null;
	ResultSet rs = null;

	public int ZC(String phone,String password){
		
		String sql = "INSERT INTO uesr_info(phone,`password`) VALUES(?,?)";
		
		int i = 0;
		try {
			Class.forName(driver);
			conn = DriverManager.getConnection(url, user, PASSWORD);
			ps = conn.prepareStatement(sql);
			ps.setString(1, phone);
			ps.setString(2, password);
			i =  ps.executeUpdate();
			
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			if(rs != null){
				try {
					rs.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			if(ps != null){
				try {
					ps.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			if(conn != null){
				try {
					conn.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
		}
	
		return i;
	}
	
}
